#!/usr/bin/python
# -*- coding: UTF-8 -*-

import tkinter as tk

# 创建窗体
window = tk.Tk()
window.title('Tk Demo')
window.geometry('350x500')

l_str = tk.StringVar()

l = tk.Label(
    window,
    textvariable=l_str,
    bg='green',
    font=('console', 12),
    width=15,
    height=2
)
l.pack()

on_click = False


def click_me():
    global on_click
    if not on_click:
        on_click = True
        l_str.set('click')
    else:
        on_click = False
        l_str.set('')


b = tk.Button(
    window,
    text='click me',
    width=15,
    height=2,
    command=click_me,
)
b.pack()

# 进入消息循环
window.mainloop()
